package com.project.lk.nurseapp.login.presenter;


import com.project.lk.nurseapp.base.BasePresenter;
import com.project.lk.nurseapp.base.ModelPresenterBridge;
import com.project.lk.nurseapp.login.model.CodeModel;
import com.project.lk.nurseapp.login.model.RegisterModel;

import java.util.List;

import static com.project.lk.nurseapp.base.BaseApi.code_fail;
import static com.project.lk.nurseapp.base.BaseApi.code_success;
import static com.project.lk.nurseapp.base.BaseApi.register_fail;
import static com.project.lk.nurseapp.base.BaseApi.register_success;


/**
 * 功能介绍：
 * 项目名：
 * 模块名称：
 * 作者：LK
 * 日期：2018/1/9
 * 修改日期：
 */
public class RegisterPresenter extends BasePresenter<IRegisterView> implements ModelPresenterBridge {

    CodeModel codeModel;
    RegisterModel registerModel;
    public RegisterPresenter(IRegisterView view){
        codeModel=new CodeModel();
        registerModel=new RegisterModel();
        registerModel.setBridge(this);
        codeModel.setBridge(this);

    }
    //获取验证码
    public void getCode(String url,String phone){
        codeModel.postLoadJson(url,phone);
    }

    //注册
    public void register(String url,String phone,String psw,String code){
        registerModel.postLoadJson(url,phone,psw,code);
    }

    @Override
    public void bridge(int action,List list) {
        if (view!=null) {
            switch (action){
                case register_fail :
                    view.registerFail();
                    break;
                case register_success :
                    view.registerSuccess();
                    break;
                case code_fail :
                    view.codeFail();
                    break;
                case code_success :
                    view.codeSuccess();
                    break;
            }
        }

    }
}
